package WinterHomework.day12;

import java.util.Arrays;

//Leetcode88号,合并两个有序数组
public class Demo02 {
    public void merge(int[] nums1, int m, int[] nums2, int n) {
        for (int i = 0; i < n; i++) {
            nums1[m + i] = nums2[i];
        }
        //Arrays.sort(nums1);
        for (int i = 0; i < m + n - 1; i++) {
            boolean flag = true;
            for (int k = 0; k < m + n - 1 - i; k++) {
                if (nums1[k] > nums1[k + 1]) {
                    int temp = nums1[k];
                    nums1[k] = nums1[k + 1];
                    nums1[k + 1] = temp;
                    flag = false;
                }
            }
            if (flag) {
                break;
            }
        }
    }
}
